<template>
    <jb-crud-page
        ref="pageRef"
        title-icon="icon-park-outline:log"
        title-text="关键操作日志"
        search-url="/api/admin/systemLog/datas"
        :search-conditions="pageConditions"
    >
        <template #conditions-form>
            <n-input
                v-model:value="pageConditions.keywords"
                type="text"
                placeholder="请输入关键字搜索"
            />
            <jb-date-range
                v-model:value="pageConditions.dateRange"
                format-pattern="yyyy-MM-dd"
            ></jb-date-range>
        </template>
        <template #opt>
            <jb-btn
                :icon="Icons.REFRESH"
                ghost
                type="primary"
                @click="pageRef?.loadData()"
            >
                刷新
            </jb-btn>
        </template>

        <template #default="{ state }">
            <vxe-table
                height="auto"
                border
                show-header-overflow
                show-overflow
                :column-config="{ resizable: true }"
                :seq-config="{ startIndex: state.tableStartIndex }"
                :row-config="{ isHover: true }"
                align="center"
                :data="state.list"
            >
                >
                <jb-column type="seq" title="序号" width="60" fixed="left"></jb-column>
                <jb-column
                    field="targetTypeName"
                    title="数据类型"
                    width="160"
                    fixed="left"
                ></jb-column>
                <jb-column
                    field="typeName"
                    title="操作类型"
                    width="140"
                    fixed="left"
                ></jb-column>
                <jb-column field="title" title="日志" min-width="400">
                    <template #default="{ row }">
                        <span v-html="row.title"></span>
                    </template>
                </jb-column>

                <jb-column field="userName" title="操作人" min-width="160"></jb-column>
                <jb-column
                    field="createTime"
                    title="记录时间"
                    min-width="200"
                ></jb-column>
            </vxe-table>
        </template>
    </jb-crud-page>
</template>

<script setup lang="ts">
import { ref } from 'vue'
import { Icons } from '@/constants'
import JbCrudPage from '@/components/_builtin/jb-crud-page/index.vue'
import { useResetableData } from '@/hooks/common/use-resetable-data'

const pageRef = ref<InstanceType<typeof JbCrudPage> | null>(null)
const pageConditions = useResetableData({
    keywords: '',
    dateRange: ''
})
</script>

<style scoped></style>
